home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 21 / Mac Magazin and MacEasy Magazine CD - Issue 21.iso / Wissenschaft & Technik / yorick12vr1-nofpu folder / include / pixels.i < prev    next >
Text File  |  1995-07-26  |  4KB  |  106 lines

  1. /*
  2.    PIXELS.I
  3.    Attempt to plot images on an X display one pixel to the cell.
  4.  
  5.    $Id$
  6.  */
  7. /*    Copyright (c) 1994.  The Regents of the University of California.
  8.                     All rights reserved.  */
  9.  
  10. func pix_window(dpi, n)
  11. /* DOCUMENT pix_window, dpi
  12.          or pix_window, dpi, n
  13.      create a new window for the pixels command with the given DPI
  14.      (dots per inch).  If N is specified, the new window will be
  15.      number N (0-7).  Also sets the pix_dpi variable appropriately.
  16.  
  17.      pix_window, 75           // makes a small window
  18.      pix_window, 100          // makes a large window
  19.  
  20.    SEE ALSO: pix_dpi, pixels, window
  21.  */
  22. {
  23.   dpi= (dpi<87.5? 75 : 100);
  24.   if (is_void(n)) window, dpi=dpi;
  25.   else window, n, dpi=dpi;
  26.   pix_dpi= dpi;
  27. }
  28.  
  29. func pixels(z,dx0,dy0,top=,cmin=,cmax=)
  30. /* DOCUMENT pixels, z
  31.          or pixels, z, dx0, dy0
  32.      plots the image Z as a cell array -- an array of equal rectangular
  33.      cells colored according to the 2-D array Z.  The first dimension
  34.      of Z is plotted along x, the second dimension is along y.
  35.      If Z is of type char, it is used "as is", otherwise it is linearly
  36.      scaled to fill the current palette, as with the bytscl function.
  37.      (See the bytscl function for explanation of top, cmin, cmax.)
  38.  
  39.      The image is placed in "coordinate system zero"; that is, outside
  40.      Yorick's ordinary coordinate system, so zooming and coordinate
  41.      system changes will not effect it.  Unlike pli, Yorick attempts
  42.      to make each X pixel correspond to one cell of the Z array.
  43.      In order to do this, the pix_dpi variable must be set to the
  44.      dots-per-inch (either 75 or 100) of the X window in which the
  45.      result of pixels will be displayed (see the dpi keyword of the
  46.      window command).
  47.  
  48.      The default position of the upper left hand corner of the picture
  49.      is specified by the pix_origin variable.  If DX0 and/or DY0 are
  50.      present, they adjust this origin for this image.  The units of
  51.      DX0 and DY0 are in pixels; DY0 is positive downwards.  (However,
  52.      the 2nd index of the image increases upwards.)  Resizing the X
  53.      window will probably necessitate changing pix_origin.
  54.  
  55.      The following keywords are legal (each has a separate help entry):
  56.    KEYWORDS: top, cmin, cmax
  57.    SEE ALSO: pix_window, window, palette, bytscl, histeq_scale
  58.              pix_dpi, pix_origin
  59.  */
  60. {
  61.   ny= dimsof(z);
  62.   nx= ny(2);
  63.   ny= ny(3);
  64.   scale= 0.0013*72.27/(pix_dpi<87.5? 75.0 : 100.0);
  65.  
  66.   if (is_void(dx0)) dx0= 0.0;
  67.   if (is_void(dy0)) dy0= 0.0;
  68.   dx0*= scale;
  69.   dy0*= -scale;
  70.   dx0+= pix_origin(1);
  71.   dy0+= pix_origin(2);
  72.  
  73.   plsys, 0;
  74.   pli, z, dx0,dy0-ny*scale,dx0+nx*scale,dy0, top=top,cmin=cmin,cmax=cmax;
  75.   plsys, 1;
  76.   redraw;   /* yes, there is a bug with detecting updates when things
  77.            in coordinate system 0 change... */
  78. }
  79.  
  80. local pix_dpi;
  81. /* DOCUMENT pix_dpi= 75
  82.          or pix_dpi= 100
  83.      set the number of dots per inch for the pixels function.
  84.      X displays are either 75 dpi (default) or 100 dpi in Yorick.
  85.      The pix_dpi number must match the dpi of the window in which
  86.      the pixels command is to be issued; the other number will
  87.      result in blurred images.
  88.  
  89.    SEE ALSO: pixels, pix_window, window
  90.  */
  91. pix_dpi= 75;
  92.  
  93. local pix_origin;
  94. /* DOCUMENT pix_origin= [0.12,0.91]
  95.      set [x,y] for the default upper left hand corner of the pixels
  96.      image.  The default value is shown.  [0,0] is the lower left of
  97.      an 8.5-by-11 sheet of paper.  Yorick units are 0.0013/point or
  98.      0.0013*72.27/inch (11 inches is a little more than 1.0);  Yorick
  99.      keeps the "middle" of an 8.5-by-11 sheet centered in the visible
  100.      part of its X windows, so you might want to change the default
  101.      pix_origin if you resize the Yorick window.
  102.  
  103.    SEE ALSO: pixels, window
  104.  */
  105. pix_origin= [0.12,0.91];
  106.